home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
UNIXLIB37B
/
!UnixLib37
/
src
/
unix
/
c
/
close
< prev
next >
Wrap
Text File
|
1996-11-09
|
1KB
|
66 lines
/****************************************************************************
*
* $Source: /unixb/home/unixlib/source/unixlib37/src/unix/c/RCS/close,v $
* $Date: 1996/10/30 21:59:01 $
* $Revision: 1.2 $
* $State: Rel $
* $Author: unixlib $
*
* $Log: close,v $
* Revision 1.2 1996/10/30 21:59:01 unixlib
* Massive changes made by Nick Burret and Peter Burwood.
*
* Revision 1.1 1996/04/19 21:35:27 simon
* Initial revision
*
***************************************************************************/
static const char rcs_id[] = "$Id: close,v 1.2 1996/10/30 21:59:01 unixlib Rel $";
#include <errno.h>
#include <fcntl.h>
#include <sys/syslib.h>
#include <sys/types.h>
#include <sys/unix.h>
#include <sys/dev.h>
#include <sys/os.h>
#include <unistd.h>
int
close (int fd)
{
register struct file *f;
if (BADF (fd))
{
errno = EBADF;
return (-1);
}
f = __u->file + fd;
if (f->dup != f)
{
register struct file *_f;
_f = f->dup;
while (_f->dup != f)
{
_f = _f->dup;
}
_f->dup = f->dup;
}
else
{
if (f->pid == __u->pid)
if (__funcall ((*(__dev[major (f->dev)].close)), (minor (f->dev), f)) < 0)
return (-1);
}
f->dup = 0;
return (0);
}